package com.github.dapeng.soa.scala

import com.github.dapeng.core._;
        import com.github.dapeng.org.apache.thrift._;
        import java.util.ServiceLoader;
        import java.util.concurrent.CompletableFuture;
        import com.github.dapeng.soa.scala.SchedualServiceAsyncCodec._;
        import com.github.dapeng.soa.scala.service.SchedualServiceAsync;
        import scala.compat.java8.FutureConverters._
        import scala.concurrent.duration._
        import scala.concurrent.Future
        import scala.concurrent.ExecutionContext.Implicits.global

        /**
         * Autogenerated by Dapeng-Code-Generator (1.2.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated

        **/
        class SchedualServiceAsyncClient extends SchedualServiceAsync {

        val serviceName = "com.github.dapeng.soa.service.SchedualService"
        val version = "1.0.0"
        val pool = {
          val serviceLoader = ServiceLoader.load(classOf[SoaConnectionPoolFactory])
          if (serviceLoader.iterator().hasNext) {
            val poolImpl = serviceLoader.iterator().next().getPool
            poolImpl.registerClientInfo(serviceName,version)
            poolImpl
          } else null
        }

        def getServiceMetadata: String = {
          pool.send(
          serviceName,
          version,
          "getServiceMetadata",
          new getServiceMetadata_args,
          new GetServiceMetadata_argsSerializer,
          new GetServiceMetadata_resultSerializer
          ).success
        }


        

            /**
            * 
            **/
            def test(
             timeout: Long = 5000) : Future[String] = {

            val response = pool.sendAsync(
            serviceName,
            version,
            "test",
            test_args(),
            new Test_argsSerializer(),
            new Test_resultSerializer()
            ,timeout).asInstanceOf[CompletableFuture[test_result]]

            toScala(response).map(_.success)

          }

          
      }
      